__author__="Kiana";
'''
python  基础练习
'''
import re;


#==========输入和输出==========
#s=input();
#print(s);

#==========数据类型===========
a = 231;
print("a的值为 %d, 类型是 %s" % (a, type(a)));
a = 231.442;
print("a的值为 %f, 类型是 %s" % (a, type(a)));
a = True;
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a = 4 + 3j;
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a = "asdsafasad";
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a = ["asdsad",True,None,12,23.32,12];#没有去重的功能
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a = ("asdsad",True,None,12,23.32,12);
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a = {"name":"Kiana","age":"18"};
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a = {"name","age","age"};#有去重的功能
print("a的值为 %s, 类型是 %s" % (a, type(a)));
a=None;
print("a的值为 %s, 类型是 %s" % (a, type(a)));

#============运算符===========
print((34+22.33)/3);
print(5 % 2);
print(5 // 2);
print(True and True);
print(True or False);
print(not False);

#=========ASCII==========
print(ord("a"));
print(chr(98));

#==========encode  && decode==========
print("addfa".encode("ASCII"));
print("中文".encode("utf-8"));
print(b'addfa'.decode("ASCII"));
print(b'\xe4\xb8\xad\xe6\x96\x87'.decode("utf-8"));

#===========sting========
#"格式化模板" % (args):模板使用 %? 进行占位，元组的元素替换模板的占位符
print("Hi %s 你好" %("Kiana",));
# * 同学你好，在*学期，你的成绩是*,提升了*
print("%s同学你好,在%02d学期，你的成绩是%.2f,提升了%.2f%%" % ("kiana",2,87.234567,15))
print(len("csda"))
print(len("这个是好吃的"))
print(len("这个是好吃的".encode("utf-8")));
print("sadaFAsaff".lower()=="sadfas");
print("vfafa".find("a"));
print("asfasfa:".replace("a","-"));

#==========正则表达式=========
print(re.match("a","kiana"));
print(re.search("a","kiana"));
# 截至5月9日，新冠病毒累计确诊人数为234例(其中海外输入77例),累计治愈456例，死亡4例，住院观察45例
pa="新冠病毒累计确诊人数为(\d+)例（其中海外输入(\d+)例），累计治愈(\d+)例，死亡(\d+)例，住院观察(\d+)例";
ta="截至5月9日，新冠病毒累计确诊人数为234例（其中海外输入77例），累计治愈456例，死亡4例，住院观察45例";
ma=re.search(pa,ta);
if ma:
    print(ma.group());
    print(ma.group(0));
    print(ma.group(1));
    print(ma.group(2));

pa='<link rel="cannonical" href="(.*?)"/>';
ta='<link rel="cannonical" href="https://gitee.com/bilias/pratice"/>';
result= re.findall(pa,ta);
print(result);

#=========list========
l=["dsa",32,34.44,None,True,32];
print(l);
l=list(range(1,10));
print(l);
#  ["index_1","index_2",...]
l=list("index_%d" % i for i in range(1,10));
print(l);
l=list("http://www.sfac.xyz/library/novel/%d" % i for i in range(1,10))
print(l);
l=list(range(1,10));
l.append(10);
print(l);
l.pop();
print(l);
l.pop(0);
print(l);
l.remove(9);
print(l);
l2=["casfas",33];
l=l+l2;
print(l);
print(l[0]);

#=========tuple========
t=tuple(range(1,10));
t=("dsa",32,34.44,None,True,32,["a","sfagag"]);
print(t);
t[6][0]="kiana";
print(t);

#===========dict=========
d={"name":"kiana","age":"18","gender":"male"};
print(d);
print(d.keys());
print(d.values());
print(d["name"]);
print(d.get("name","aaa"));
d["abcd"]="cvbn";
print(d);
d2={"ccc":"ddd","eee":"fff"};
print(dict(d,**d2));
d.pop("age");
print(d);

#============set=========
s={"name","age","gender"};
print(s);
s=set(list(range(1,10)));
print(s);
s.pop();
print(s);
s.remove(5);
print(s);

#=========判断语句、循环语句=======
age=20;
if age<=18:
    print("儿童");
elif age>18 and age<=60:
    print("成年人");
else:
    print("老年人")

l=list(range(1,10));
for i in l:
    print(i);

i=0;
while i<10:
    print(i);
    i=i + 1;

a="study" if age<=18 else "work";
print(a);

#===========变量=========
_a="cdsacad";
__a="dasggss";
HUMAN_NAME="fsdgsd";
#内建作用于 > 全局作用于 > 闭包作用于 > 局部作用于